package com.xnyzc.lhy.common.penum;

import com.xnyzc.lhy.common.entity.PEnum;

/**
 * @Description:
 * @Author: scootXin
 * @Date: 2019/5/16 16:42
 */
public enum ECustomerLogAct implements PEnum<String> {

    visit("查看", ECustomerLogScope.fm, ECustomerLogScope.merchant, ECustomerLogScope.freeSheet), concat("联系", ECustomerLogScope.fm,
            ECustomerLogScope.merchant), judge("评价", ECustomerLogScope.fm, ECustomerLogScope.merchant), order("订单", ECustomerLogScope.fm,
            ECustomerLogScope.merchant), help("维权", ECustomerLogScope.fm), like("点赞", ECustomerLogScope.fm), fee("消费", ECustomerLogScope.merchant,
            ECustomerLogScope.freeSheet), newCustCoupon("领取新用户优惠券", ECustomerLogScope.merchant), couponGet("领取优惠券", ECustomerLogScope.merchant),
    couponConsume("消费优惠券", ECustomerLogScope.merchant), freeSheet("参加免单季", ECustomerLogScope.merchant, ECustomerLogScope.freeSheet);

    private String desc;
    private ECustomerLogScope[] allow;

    ECustomerLogAct(String desc, ECustomerLogScope... allow) {
        this.desc = desc;
        this.allow = allow;
    }

    @Override
    public String getValue() {
        return name();
    }

    @Override
    public String toString() {
        return name();
    }

    @Override
    public String toChString() {
        return desc;
    }

    /**
     * 该类型是否支持该操作
     *
     * @param scope
     * @return
     */
    public boolean couldAct(ECustomerLogScope scope) {
        for (ECustomerLogScope s : allow) {
            if (scope == s) {
                return true;
            }
        }

        return false;
    }
}
